package objects;

import helpers.FinDate;

import java.util.ArrayList;

import managers.BinManager;
import managers.TransactionManager;

public class Bin {
	private int binNumber;
	private String name;
	private long desiredAmount;
	private FinDate desiredAmountDate;
	
	public Bin (int binNumber, String name, long desiredAmount, FinDate desiredAmountDate) {
			this.binNumber = binNumber;
			this.name = name;
			this.desiredAmount = desiredAmount;
			this.desiredAmountDate = desiredAmountDate;
		//	BinManager.addBin(this);		
	}
	
	public Bin (String name, long desiredAmount, FinDate desiredAmountDate){
		this(BinManager.generateBinNumber(), name, desiredAmount, desiredAmountDate);	
	}
	
	public Bin (String name) {
		this(BinManager.generateBinNumber(), name, -1, null);	
	}
	
	
	public Bin (int binNumber) {
		//TODO initialize Bin from stored database	
	}
	
	private long getMoneyInThisBin() {
		ArrayList<Transaction> transactions = TransactionManager.getTransactionsByBinNumber(this.binNumber);
		long out = 0;
		for(Transaction t : transactions) {
			out += t.getAmount();			
		}
		
		return out;
	}

	public int getBinNumber() {
			return this.binNumber;
	}

	public String getBinName() {
		return this.name;
	}
}
